/**
 * @fileOverview 路由配置
 * @date         2015/10/12
 * @author       chenlu
 */
define(['app', 'config'], function(app, config) {
	return app.config(function($controllerProvider, $routeProvider) {
		function C(templateUrl, controllerName) {
			return {
				templateUrl: config.PATH.ROOT + config.PATH.VIEW + templateUrl,
				controller: controllerName,
				resolve: {
					delay: function($q, $rootScope) {
						var defer = $q.defer();
						require([config.PATH.CONTROLLER + controllerName], function(controller) {
							$controllerProvider.register(controllerName, controller);
							defer.resolve();
							$rootScope.$apply()
						})
						return defer.promise;
					}
				}
			}
		}

		$routeProvider
			.when('/', C('default.html', 'default'))
			.when('/company/list', C('company/list.html', 'companyList'))
			.otherwise({ redirectTo: '/' });
	});
});